package Controller

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"strconv"
	"time"
	"web_back_go/DAO/gorm"
	"web_back_go/DAO/gorm/GormModel"
	"web_back_go/Response"
)

func GetSkuListByProdId(c *gin.Context) {
	prodIdStr := c.Query("prodId")
	prodId, err := strconv.Atoi(prodIdStr)
	if err != nil {
		// 处理错误，例如返回错误响应或设置默认值
		c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid prodId"})
		return
	}

	var skus []GormModel.TzSku
	gorm.Db.Where("status = ? and is_delete = ? and prod_id = ?", 1, 0, prodId).Find(&skus)
	c.JSON(200, Response.ResponseBody{
		Code:      "200",
		Data:      skus,
		Msg:       nil,
		Version:   "V1.0.0",
		Success:   true,
		Timestamp: time.Now().Unix(),
	})
}
